﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Buoi02
{
    abstract class CPoint2D
    {
        //Properties
        public abstract double X
        {
            get;
            set;
        }

        public abstract double Y
        {
            get;
            set;
        }

        // Methods
        // Gán tọa độ mới. Giá trị lấy từ x,y.
        public abstract void SetLocation(double x, double y);

        // Gán tọa độ mới từ một tọa độ có sẳn.
        public void SetLocation(CPoint2D p)
        {

        }

        // Tính khoảng cách giữa hai điểm A(xA, yA) và B(xB, yB).
        public static double Distance(double xA, double yA, double xB, double yB)
        {
            return 0;
        }

        // Tính khoảng cách đến điểm P(xP, yP).
        public double Distance(double xP, double yP)
        {
            return 0;
        }

        // Tính khoảng cách đến điểm p.
        public double Distance(CPoint2D p)
        {
            return 0;
        }

        public class CFloat : CPoint2D
        {
            // Fields
            float m_X;
            float m_Y;

            // Contructors
            public CFloat()
            {
                m_X = 0;
                m_Y = 0;
            }

            public CFloat(float x, float y)
            {
                m_X = x;
                m_Y = y;
            }

            public CFloat(CFloat f)
            {
                m_X = f.m_X;
                m_Y = f.m_Y;
            }

            // Properties
            public override double X
            {
                get
                {
                    return m_X;
                }
                set
                {
                    m_X = (float)value;
                }
            }

            public override double Y
            {
                get
                {
                    return m_Y;
                }
                set
                {
                    m_Y = (float)value;
                }
            }

            // Methods
            public override void SetLocation(double x, double y)
            {
                m_X = (float)x;
                m_Y = (float)y;
            }

            public override string ToString()
            {
                return "X: " + m_X + ", Y: " + m_Y;
            }

        }

        public class CDouble : CPoint2D
        {
            // Fields
            double m_X;
            double m_Y;

            // Contructors
            public CDouble()
            {
                m_X = 0;
                m_Y = 0;
            }

            public CDouble(double x, double y)
            {
                m_X = x;
                m_Y = y;
            }

            public CDouble(CDouble f)
            {
                m_X = f.m_X;
                m_Y = f.m_Y;
            }

            // Properties
            public override double X
            {
                get
                {
                    return m_X;
                }
                set
                {
                    m_X = value;
                }
            }

            public override double Y
            {
                get
                {
                    return m_Y;
                }
                set
                {
                    m_Y = value;
                }
            }

            // Methods
            public override void SetLocation(double x, double y)
            {
                m_X = x;
                m_Y = y;
            }

            public override string ToString()
            {
                return "X: " + m_X + ", Y: " + m_Y;
            }
        }
    }

    class CPoint : CPoint2D
    {
        // Fields
        int m_X;
        int m_Y;

        // Contructors
        public CPoint()
        {
            m_X = 0;
            m_Y = 0;
        }

        public CPoint(int x, int y)
        {
            m_X = x;
            m_Y = y;
        }

        public CPoint(CPoint f)
        {
            m_X = f.m_X;
            m_Y = f.m_Y;
        }

        // Properties
        public override double X
        {
            get
            {
                return m_X;
            }
            set
            {
                m_X = (int)value;
            }
        }

        public override double Y
        {
            get
            {
                return m_Y;
            }
            set
            {
                m_Y = (int)value;
            }
        }

        // Methods
        public override void SetLocation(double x, double y)
        {
            m_X = (int)x;
            m_Y = (int)y;
        }

        public override string ToString()
        {
            return "X: " + m_X + ", Y: " + m_Y;
        }
    }
}
